#include <stdio.h>
float deal_image_data(float image_longth, float x_grass){
// the image_longth prerents the images's lonth and the x_grass prerents the x coodinate	
//the next step is going to assign for the diffrent distance
    float m1=image_longth*0.2;     //the first  distance to the camera
    float m2=image_longth*0.4;     //the second distance to the camera
    float m3=image_longth*0.6;     //the third  distance to the camera
    float m4=image_longth*0.8;     //the forth  distance to the camera
    float m5=image_longth;         //the fifth  distance to the camera
    float real_distance;
// the next step will decide which distance argorithm will be used

     //the next choose will cauculate the first farse real distance
     if (x_grass>0 && x_grass<m1)
     {
     	 real_distance=x_grass*10;
     }

     //the next choose will cauculate the second farse real distance
     else if (x_grass>=m1 && x_grass<m2)
     {

         real_distance=image_longth*2+(x_grass - image_longth*0.2)*30;	
     }

     //the next choose will cauculate the third farse real distance
     else if (x_grass>=m2 && x_grass<m3)
     {

         real_distance=image_longth*2+image_longth*6+(x_grass - image_longth*0.4)*50;	
     }

     //the next choose will cauculate the fourth farse real distance
     else if (x_grass>=m3 && x_grass<m4)
     {
         real_distance=image_longth*2+image_longth*6+image_longth*10+(x_grass-image_longth*0.6)*70;

     //the next choose will cauculate the fifth farse real distance
     }     
     else if (x_grass>=m4 && x_grass<=m5)
     {
         real_distance=image_longth*2+image_longth*6+image_longth*10+image_longth*14+(x_grass- image_longth*0.8)*90;
     }
     else
     {
         real_distance=12345;
     }
     return real_distance;
}	
int main(){
	float longth=100;
	float x_axis=3;
	float real_distance1=deal_image_data(longth,x_axis);
	printf("\n after cauculate the real_distance is %f \n",real_distance1);
	return 0;
}